Below is a list of all the mathematical commands available in CALUMATH.
Command | Description | Example |
CM_Round | CM_Round(x,n) rounds the number x. If n is not entered, x is rounded to the nearest integer. If n is an integer in the range 0 to 15, x is rounded off to n decimal places. If n=.5, the number x is rounded to the nearest half; if n=.25, x is rounded to the nearest quarter. | CM_Round(12.34567890123) and CM_Round(12.34567890123, 0) both return 12. CM_Round(12.34567890123, 5) returns 12.34568. CM_Round(12.34567890123, .25) returns 12.25. CM_Round(12.34567890123, .5) returns 12.5. |
CM_AbsoluteValue | Returns the absolute value of number | CM_AbsoluteValue(-3) returns 3. CM_AbsoluteValue(5) returns 5. |
CM_Max | Returns the largest of the entered numbers. | CM_Max(1,-4,3,5,2) returns 5. |
CM_Min | Returns the smallest of the entered numbers. | CM_Min(1,-4,3,5,2) returns -4. |
CM_Floor | CM_Floor(x) returns the largest integer that is less than or equal to x. | CM_Floor( 5.2) = 5. CM_Floor(7)=7. CM_Floor(-5.3)= -6. |
CM_Ceiling | CM_Ceiling(x) returns the smallest integer that is greater than or equal to x. | CM_Ceiling( 5.2) = 6. CM_Ceiling(7)=7. CM_Ceiling(-5.3)= -5. |
sin, cos, tan, sec, csc, cot | returns the sin, cos, tan, sec, csc, or cot of an angle (expressed in radians) | sin(pi/2) returns 1. cos(0) returns 1. tan(pi/4) returns 1. |
arcsin, arccos, arctan, arccot | returns the arcsin, arccos, arctan, or arccot (expressed in radians) of a number. | arcsin(1) returns 1.5707963267948966 (which is a decimal approximation for pi/2). |
Heaviside | Heaviside(x) returns 0 if x <0 and 1 if x >= 0. | Heaviside(-1) returns 0. Heaviside(0) returns 1. |
modn | modn(x,n) returns the remainder when x is divided by n. | modn(10,3) returns 1. modn(30,7) returns 2. modn(-30,7) returns -2. The sign of the remainder is determined by the sign of x. |
cm_eval | cm_eval is used in a text field (such as a paragraph) when you want to replace an expression by its value. Note: if you want to replace a mathematical expression by its value, you must use cm_evalm instead of cm_eval. | Suppose you previously defined the constant A=5. In a paragraph, entering A= cm_eval(A) will produce the output A=5 in the paragraph. If A is the array [1,2,3,4], entering A=cm_eval(A) will produce A=1,2,3,4. Note that when arrays are displayed, the openning and closing brackets are not displayed. |
cm_evalm | cm_evalm is used in a text field (such as a paragraph) when you want to replace a mathematical expression that evaluates to a number by its number value. | In a paragraph, entering A= cm_evalm(pi/2) will produce the output A=1.5707963267948966; A= cm_evalm(CM_Round(pi/2,3)) will produce the output A=1.571. Note that A= cm_eval(pi/2) will produce an error, since mathematical expressions must be evaluated using cm_evalm, not cm_eval. |
Below is a list of all the Array commands available in CALUMATH. Note that all Array commands are invoked using the dot notation from computer science; for example if A is an Array, you invoke the cm_concat command by entering A.cm_concat(), not by cm_concat(A).
[ ] | Entries in an Array are numbered starting at 0. If A is an Array, A[k] returns the k th entry of A. | If A= ["a","b","c"], then A[0] returns "a" and A[2] returns "c". If B=[1,2,[3,4],[5,6]], then B[2] returns [3,4], since entry number 2 in B is the Array [3,4]. |
length | Returns the length of the Array. | If A=[1,2,3]; then A.length returns 3. If B=[1,2,[3,4],[5,6]], then B.length returns 4. |
cm_display | This displays the array with all openning and closing braces visible. This command is necessary, because normally Arrays are displayed without any openning or closing brackets visible. | If A= [[1,2],[3,4]], then A.cm_display() returns [[1,2],[3,4]]; without this command A would be displayed as 1,2,3,4. |
cm_concat | This concatenates elements to an Array. The original Array is not altered, a copy of it with the new elements concatenated is returned. | If A=[1,2,3], then A.cm_concat(4,5) returns [1,2,3,4,5] and A.cm_concat(4, [5,6]) returns [1,2,3,4,[5,6]]. If you want A to refer to the new, concatenated array, you must define A=A.cm_concat(4, [5,6]). |
cm_contains | This returns true if the Array contains the indicated element; it returns false otherwise. | If A=["a","b",1,2,3], then A.cm_contains(2) returns true; A.cm_contains("d") returns false. If B= [[1,2],[3,4]], B.cm_contains([1,2]) returns true. |
cm_and | This returns the elements that are common to two Arrays. | If A=[1,2,3,4,5] and B=[-2,3,5,8,9], then A.cm_and(B) returns the Array [3,5]. |
cm_or | This returns the elements that are in either of two Arrays. | If A=[1,2,3,4,5] and B=[-2,3,5,8,9], then A.cm_or(B) returns the Array [ 1,2,3,4,5,-2,8,9 ]. Note that the elements of B that are not contained in A are added to the end of the returned Array. |
cm_andpoints | This is specifically used for Arrays which are arrays of points, namely, if they are of the form [[x1,y1], [x2,y2], ... , [xn,yn]]. It returns the points in common to both Arrays. | If A=[[1,2],[3,4],[5,6] ] and B=[[-1,-2], [3,4],[5,6], [7,8]], then A.cm_andpoints(B) returns [ [ 3,4 ],[ 5,6 ] ]. |
cm_orpoints | This is specifically used for Arrays which are arrays of points, namely, if they are of the form [[x1,y1], [x2,y2], ... , [xn,yn]]. It returns the points in either Array. | If A=[[1,2],[3,4],[5,6] ] and B=[[-1,-2], [3,4],[5,6], [7,8]], then A.cm_orpoints(B) returns [ [ 1,2 ],[ 3,4 ],[ 5,6 ],[ -1,-2 ],[ 7,8 ] ]. Note that the points of B that are not contained in A are added to the end of the returned Array. |
cm_complementpoints | This is specifically used for Arrays which are arrays of points, namely, if they are of the form [[x1,y1], [x2,y2], ... , [xn,yn]]. It returns the points of the first Array that are not in the second Array. | If A=[[1,2],[3,4],[5,6] ] and B=[[-1,-2], [3,4],[5,6], [7,8]], then A.cm_complementpoints(B) returns [ [ 1,2 ] ]. |
cm_sortpoints | This is used with Arrays of points, in other words Arrays of the form [[x1,y1], [x2,y2], ... , [xn,yn]]. It allows you to choose, which variable to sort the points by (either x or y), and to choose whether to sort in ascending or descending order. If two coordinates are equal, it allows you to choose whether the other coordinates should be ascending or descending. |
If A=[[1,10],[5,4], [3,4], [5,6] ], then A.cm_sortpoints("x","a", "a") indicates that A should be sorted by increasing (because of the first "a") x coordinate. In addition, if two points have the same x coordinate, the points should be sorted by increasing y value (because of the second "a"). Therefore A.cm_sortpoints("x","a", "a") returns [ [ 1,10 ],[ 3,4 ],[ 5,4 ],[ 5,6 ] ]. A.cm_sortpoints("x","a", "d") returns [ [ 1,10 ],[ 3,4 ],[ 5,6 ],[ 5,4 ] ]; since the points [5,4] and [5,6] have the same x coordinate, they are sorted by descending y coordinate (indicated by the "d"). A.cm_sortpoints("y","a", "a") returns [ 3,4 ],[ 5,4 ],[ 5,6 ],[ 1,10 ] ]. A.cm_sortpoints("y","a", "d") returns [ 5,4 ],[ 3,4 ],[ 5,6 ],[ 1,10 ] ]; since the points [5,4] and [3,4] have the same y coordinate, they are sorted by descending x coordinate (indicated by the "d"). In general, for an Array of points A the first "x" or "y" determines the variable that is sorted, the first "a" or "d" determines how the variable is sorted (either ascending or descending), and the second "a" or "d" determines how the other variable is sorted if two points have the same first variable value. |
cm_average | If an Array contains entries that are numbers, this returns the average of the Array entries. | If A=[1,2,3,4,5,6] then A.cm_average() returns 3.5. |
cm_transposematrix | This is used only for a double array (an Array each of whose elements is an Array). This returns the transpose of the Array. | If A=[[1,2],[3,4],[5,6] ], then this can be identified with a Matrix with three rows and two columns. The first row consists of 1,2, the second row consists of 3,4 and the third row consists of 5,6. The transpose of this Matrix is the Matrix obtained by interchanging the rows and columns. Therefore A.cm_transpose() returns [[ 1,3,5 ],[ 2,4,6 ] ]. This is a Matrix with two rows and three columns. Each column of the returned Matrix was a row of A. |
cm_choosecolumns | This is used only for a double array (an Array each of whose elements is an Array). This returns the Array consisting of the chosen columns of the Array. | If A=[[1,2,3,4],[5,6,7,8],[9,10,11,12] ] then A.cm_choosecolumns(1,2) returns [ [ 2,3 ],[ 6,7 ],[ 10,11 ] ] which is the Array consisting of the columns numbered 1 and 2 of A (recall that entries of an Array are numbered beginning with 0). |
cm_chooserows | This is used only for a double array (an Array each of whose elements is an Array). This returns the Array consisting of the chosen rows of the Array. | If A=[[1,2,3,4],[5,6,7,8],[9,10,11,12] ] then A.cm_chooserows(1,2) returns [ [ 5,6,7,8 ],[ 9,10,11,12 ] ] which is the Array consisting of the rows numbered 1 and 2 of A (recall that entries of an Array are numbered beginning with 0). |
cm_applyfunction | This applies the indicated function to each element of the Array. | If f(x) = x^2 and A=[[1,2,3,4],[5,6,7,8],[9,10,[11,12]] ] then A.cm_applyfunction(f) returns [ [ 1,4,9,16 ],[ 25,36,49,64 ],[ 81,100,[ 121,144 ] ] ]. This is the result of applying f to each entry of A and the entries in each Array contained in A. |
cm_strictlyincreasingpoints | This is used with Arrays of points, in other words Arrays of the form [[x1,y1], [x2,y2], ... , [xn,yn]]. cm_strictlyincreasingpoints first sorts the points in increasing order of x, in other words it creates a new array [[x1',y1'], [x2',y2'], ... , [xn',yn']] of the same length n and consisting of the same points,however now x1' <= x2' <= x3' ... <= xn'. It then checks whether y1'< y2'< y3' ... <yn' . If this is true, it returns "yes". If this is not true, it returns an Array consisting of the first two points [[x_i', y_i'], [x_i+1', y_i+1']] for which y_i' >= y_i+1'. | If B=[[1,2],[5,6], [3,4] ], then B.cm_strictlyincreasingpoints() returns "yes", since when the points are rearranged in terms of increaing x values, consecutive y values are increasing. If A=[[1,2],[3,4],[5,6], [3.5,2] ], then A.cm_strictlyincreasingpoints() returns [ [ 3,4 ],[ 3.5,2 ] ], since after the points are sorted by their x coordinates, the y coordinate in [3,4] is greater than the y coordinate in [3.5,2]. |
cm_increasingpoints | This is exactly the same as cm_strictlyincreasingpoints except it allows for y values to be equal. As with cm_strictlyincreasingpoints, this is used with Arrays of points, in other words Arrays of the form [[x1,y1], [x2,y2], ... , [xn,yn]]. cm_strictlyincreasingpoints first sorts the points in increasing order of x, in other words it creates a new array [[x1',y1'], [x2',y2'], ... , [xn',yn']] of the same length n and consisting of the same points,however now x1' <= x2' <= x3' ... <= xn'. It then checks whether y1'<= y2'<= y3' ... <=yn'. If this is true, it returns "yes". If this is not true, it returns an Array consisting of the first two points [[x_i', y_i'], [x_i+1', y_i+1']] for which y_i' > y_i+1'. | If B=[[1,2],[5,6], [3,2] ], then B.cm_strictlyincreasingpoints() returns "yes", since when the points are rearranged in terms of increaing x values, consecutive y values are either equal or increasing. If A=[[1,2],[3,4],[5,6], [3.5,2] ], then A.cm_strictlyincreasingpoints() returns [ [ 3,4 ],[ 3.5,2 ] ], since after the points are sorted by their x coordinates, the y coordinate in [3,4] is greater than the y coordinate in [3.5,2]. |
cm_strictlydecreasingpoints | This is used with Arrays of points, in other words Arrays of the form [[x1,y1], [x2,y2], ... , [xn,yn]]. cm_strictlydecreasingpoints first sorts the points in increasing order of x, in other words it creates a new array [[x1',y1'], [x2',y2'], ... , [xn',yn']] of the same length n and consisting of the same points,however now x1' <= x2' <= x3' ... <= xn'. It then checks whether y1'> y2'> y3' ... > yn'. If this is true, it returns "yes". If this is not true, it returns an Array consisting of the first two points [[x_i', y_i'], [x_i+1', y_i+1']] for which y_i' <= y_i+1'. | If B=[[1,10],[5,4], [3,6] ], then B.cm_strictlydecreasingpoints() returns "yes", since when the points are rearranged in terms of increaing x values, consecutive y values are decreasing. If A=[[1,10],[5,4],[3,6],[3.5,2]], then A.cm_strictlydecreasingpoints() returns [ [ 3.5,2 ],[ 5,4 ] ], since after the points are sorted by their x coordinates, the y coordinate in [5,4] is greater than the y coordinate in [3.5,2]. |
cm_decreasingpoints | This is exactly the same as cm_strictlydecreasingpoints except it allows for y values to be equal. As with cm_strictlydecreasingpoints, this is used with Arrays of points, in other words Arrays of the form [[x1,y1], [x2,y2], ... , [xn,yn]]. cm_strictlydecreasingpoints first sorts the points in decreasing order of x, in other words it creates a new array [[x1',y1'], [x2',y2'], ... , [xn',yn']] of the same length n and consisting of the same points,however now x1' <= x2' <= x3' ... <= xn'. It then checks whether y1'>= y2'>= y3' ... >=yn'. If this is true, it returns "yes". If this is not true, it returns an Array consisting of the first two points [[x_i', y_i'], [x_i+1', y_i+1']] for which y_i' <= y_i+1'. | If B=[[1,10],[5,4], [3,4] ], then B.cm_decreasingpoints() returns "yes", since when the points are rearranged in terms of increaing x values, consecutive y values are equal or decreasing. If A=[[1,10],[5,4],[3,6],[3.5,2]], then A.cm_decreasingpoints() returns [ [ 3.5,2 ],[ 5,4 ] ], since after the points are sorted by their x coordinates, the y coordinate in [5,4] is greater than the y coordinate in [3.5,2]. |